﻿<Window x:Class="MovieCollection.WebSearchResultWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:movieCollection="clr-namespace:MovieCollection"
    Title="{LocText MovieCollection::WebSearchResultTitle}" Height="550" Width="800" WindowStartupLocation="CenterScreen"
    x:Name="webSearchResultWindow" WindowStyle="ToolWindow" Loaded="webSearchResultWindow_Loaded" Icon="Icons/folder_video.png">
    <Window.Resources>
        <movieCollection:ListToStringConverter x:Key="listToString" />
        <movieCollection:DictionaryToStringConverter x:Key="dicToString" />
    </Window.Resources>
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="200" />
            <ColumnDefinition Width="130" />
            <ColumnDefinition Width="Auto" MinWidth="75" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>        
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" MinHeight="29" />
            <RowDefinition Height="Auto" MinHeight="28" />
            <RowDefinition Height="Auto" MinHeight="27" />
            <RowDefinition Height="Auto" MinHeight="26" />
            <RowDefinition Height="Auto" MinHeight="25" />
            <RowDefinition Height="Auto" MinHeight="25" />
            <RowDefinition Height="Auto" MinHeight="24" />
            <RowDefinition Height="Auto" MinHeight="21" />
            <RowDefinition />
            <RowDefinition Height="32" />
        </Grid.RowDefinitions>
        
        <ListBox x:Name="listBoxResults" Grid.Column="0" Grid.Row="0" Grid.RowSpan="10" SelectionChanged="listBoxResults_SelectionChanged">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition />
                            <RowDefinition />
                        </Grid.RowDefinitions>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition/>
                        </Grid.ColumnDefinitions>

                        <TextBlock Text="{Binding Path=Title}" Grid.Column="1" Grid.Row="0" FontWeight="Bold" />
                        <TextBlock Text="{Binding Path=OriginalTitle}" Grid.Column="1" Grid.Row="1" 
                               Foreground="Gray"/>
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        <TextBlock Grid.Column="1" Grid.ColumnSpan="3" Grid.Row="0" Margin="10 5 5 2.5" FontSize="16" FontWeight="Bold" 
                   Text="{Binding SelectedDetails.Title, ElementName=webSearchResultWindow}" />
        <Image x:Name="imageCover" Grid.Column="1" Grid.Row="1" Grid.RowSpan="6" Width="120" Height="160" Margin="5"
               Source="{Binding SelectedDetails.ImageURL, ElementName=webSearchResultWindow}" />

        <TextBlock Grid.Column="2" Grid.Row="1" Text="{LocText MovieCollection::LabelOriginalTitle}" 
                           Margin="2.5" HorizontalAlignment="Right" VerticalAlignment="Center" />
        <TextBlock Grid.Column="3" Grid.Row="1" Margin="2.5" VerticalAlignment="Center" FontWeight="Bold" 
                   Text="{Binding SelectedDetails.OriginalTitle, ElementName=webSearchResultWindow}" />
        <TextBlock Grid.Column="2" Grid.Row="2" Text="{LocText MovieCollection::LabelDirector}" 
                           Margin="2.5" HorizontalAlignment="Right" VerticalAlignment="Center" />
        <TextBlock Grid.Column="3" Grid.Row="2" Margin="2.5"  VerticalAlignment="Center" FontWeight="Bold" 
                   Text="{Binding SelectedDetails.Director.Name, ElementName=webSearchResultWindow}" />
        <TextBlock Grid.Column="2" Grid.Row="3" Text="{LocText MovieCollection::LabelYear}" 
                           Margin="2.5" HorizontalAlignment="Right" VerticalAlignment="Center" />
        <TextBlock Grid.Column="3" Grid.Row="3" Margin="2.5"  VerticalAlignment="Center" FontWeight="Bold" 
                   Text="{Binding SelectedDetails.Year, ElementName=webSearchResultWindow}" />
        <TextBlock Grid.Column="2" Grid.Row="4" Text="{LocText MovieCollection::LabelCountry}" 
                           Margin="2.5" HorizontalAlignment="Right" VerticalAlignment="Center" />
        <TextBlock Grid.Column="3" Grid.Row="4" Margin="2.5"  VerticalAlignment="Center" FontWeight="Bold" 
                   Text="{Binding SelectedDetails.Country, ElementName=webSearchResultWindow}" />
        <TextBlock Grid.Column="2" Grid.Row="5" Text="{LocText MovieCollection::LabelRating}" 
                           Margin="2.5" HorizontalAlignment="Right" VerticalAlignment="Center" />
        <TextBlock Grid.Column="3" Grid.Row="5" Margin="2.5"  VerticalAlignment="Center" FontWeight="Bold" 
                   Text="{Binding SelectedDetails.Rating, ElementName=webSearchResultWindow}" />
        <TextBlock Grid.Column="2" Grid.Row="6" Text="{LocText MovieCollection::LabelGenre}" 
                           Margin="2.5" HorizontalAlignment="Right" VerticalAlignment="Center" />
        <TextBlock Grid.Column="3" Grid.Row="6" Margin="2.5"  VerticalAlignment="Center" FontWeight="Bold" 
                   Text="{Binding SelectedDetails.Genres, ElementName=webSearchResultWindow, Converter={StaticResource listToString}}" />
        
        <TextBlock Grid.Column="1" Grid.Row="7" Text="{LocText MovieCollection::LabelCast}" 
                           Margin="2.5" HorizontalAlignment="Right" VerticalAlignment="Top" />
        <TextBlock Grid.Column="2" Grid.ColumnSpan="2" Grid.Row="7" Margin="2.5 2.5 5 2.5"  VerticalAlignment="Top" TextWrapping="Wrap" 
                   Text="{Binding SelectedDetails.Cast, ElementName=webSearchResultWindow, Converter={StaticResource dicToString}}" Width="Auto" />

        <TextBlock Grid.Column="1" Grid.Row="8" Text="{LocText MovieCollection::TextBlockPlot}" 
                           Margin="2.5" HorizontalAlignment="Right" VerticalAlignment="Top" />
        <TextBlock Grid.Column="2" Grid.ColumnSpan="2" Grid.Row="8" Margin="2.5 2.5 5 2.5"  VerticalAlignment="Top" TextWrapping="Wrap" 
                   Text="{Binding SelectedDetails.Plot, ElementName=webSearchResultWindow}" TextAlignment="Justify" Width="Auto" />
        <Grid Grid.Column="1" Grid.ColumnSpan="3" Grid.Row="9" Width="Auto">
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            
        <CheckBox x:Name="checkBoxAutoSelect" Grid.Column="0" Grid.Row="0" Checked="checkBoxAutoSelect_Checked" VerticalAlignment="Center" VerticalContentAlignment="Center" Margin="10,5,5,8.02">
            <TextBlock Text="{LocText MovieCollection::AutoSelectIfOnlyOne}" />
        </CheckBox>
            <Button x:Name="buttonOK" Grid.Column="1" Grid.Row="0" Content="{LocText MovieCollection::ButtonOk}" Margin="5" MinWidth="100"
                    Click="buttonOK_Click" />
            <Button x:Name="buttonCancel" Grid.Column="2" Grid.Row="0" Content="{LocText MovieCollection::ButtonCancel}" Margin="5" MinWidth="100"
                    Click="buttonCancel_Click" />
        </Grid> 
    </Grid>
</Window>
